  <?php if(!empty($id)) { ?>
 <form action="<?= $admin_base_url; ?>product/edit/<?=$id;?>/<?php echo $cur_page;?>" method="post" id="product_form" enctype="multipart/form-data">
 <?php } else { ?>
 <form action="<?= $admin_base_url; ?>product/add/<?= $cur_page;?>" method="post" id="product_form" enctype="multipart/form-data">
 <?php } ?>
 
<table  id="tblform">
<tbody>
	<tr>
		<td>Code</td>
		<td><input class="input" type="text" name="code" value="<?php echo $product['code'];?>" /></td>
	</tr>
    <tr>
		<td>Name</td>
		<td><input class="input" type="text" name="name" value="<?php echo $product['name'];?>" /></td>
	</tr>
    <tr>
		<td>Category</td>
		<td><select  id="category"><option value=""> Select</option>
        <?php
		if(!empty($category)) 
		{
	foreach($category as $key => $record) 
	{
		echo "<option ";
		if($p_id==$record['id'])
		echo "selected";
		
		
		echo  " value='".$record['id']."'>".$record['name']." </option>";
	}
		}
	?>
         </select>
       </td>
	</tr>
    <tr>
    <td>
    Sub category
    </td>
    <td>
    <select id="subcategory" name="category">
    <?php
		if(!empty($subcategory)) 
		{
	foreach($subcategory as $key => $record) 
	{
		echo "<option ";
		if($product['category']==$record['id'])
		echo "selected";
		
		
		echo  " value='".$record['id']."'>".$record['name']." </option>";
	}
		}
	?>
    </select>
    
    </td>
    </tr>
    <tr>
		<td>Description</td>
		<td><textarea name="description"><?php echo $product['description'];?> </textarea></td>
	</tr>
    <tr>
		<td>Picture</td>
		<td><input class="input" type="file" name="picture"  />
        <?php
		if(!empty($product['image']))
		{
			?><br/>
            <img src="<?=$image_path;?>products/<?=$product['id'];?>.<?=$product['image'];?>" height="70" width="70" />
            <?php
		}
		?>
        </td>
	</tr>
    <tr>
		<td>Quantiy</td>
		<td><input class="input" type="text" name="size" value="<?php echo $product['size'];?>" /></td>
	</tr>
    <tr>
		<td>Cost</td>
		<td><input class="input" type="text" name="cost" value="<?php echo $product['cost'];?>" /></td>
	</tr>
    <tr>
		<td>Special Cost</td>
		<td><input class="input" type="text" name="special_cost" value="<?php echo $product['special_cost'];?>" /></td>
	</tr>
    <tr>
		<td colspan="2"><input class="input" type="checkbox" name="special" value="1" <?php if($product['special']==1) echo "checked"; ?> /> Is this special product ?</td>
	</tr>
    
	<tr>
		<td>&nbsp;</td>
		<td>     
			<div class="buttons">
			    <button type="submit" name="save" class="positive" value="save" >
			        <img src="<?php echo $admin_image_path?>icons/apply.png" alt=""/>
			          <?php if(!empty($id)) { ?>
 							Update product
 							<input type="hidden" name="id" value="<?php echo $id;?>" />
                       
 							<input  type="hidden" name="rurl" value="<?php echo $rurl;?>" />
 					  <?php } else { ?>
 					  	Add product
 					  	<?php } ?>

 			    </button>
			   <a href="<?= $admin_base_url; ?>product/cancel?rurl=<?php echo $rurl;?>" class="negative">
			        <img src="<?php echo $admin_image_path?>icons/cross.png" alt=""/>
			        Cancel
			   </a>
			</div>
		</td>
	</tr>
</tbody>
</table>
 </form>
 <script>
 $(document).ready(function() {
     $("#course_form").RSV({
       onCompleteHandler: frmSubmit,
       errorFieldClass: "errorDesc",
       displayType: "display-html",
       errorHTMLItemBullet: "&#8212; ",
             rules: [
                     "required,name,Please enter name."
             ]
     });
  // a custom onComplete handler to prevent form submits for the demo
     function frmSubmit()
     {
       return true;
     }

        
});
 </script>